package com.cn.lp.feign.base;

import com.cn.lp.feign.processor.GetRequestParamParameterProcessor;
import com.cn.lp.feign.processor.RequestHeaderParamParameterProcessor;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
import org.springframework.cloud.openfeign.AnnotatedParameterProcessor;
import org.springframework.cloud.openfeign.annotation.RequestHeaderParameterProcessor;
import org.springframework.cloud.openfeign.annotation.RequestParamParameterProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;

@Configuration
@ComponentScan(basePackages = "org.springframework.cloud.openfeign.annotation",
includeFilters = {
    @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {AnnotatedParameterProcessor.class})
},
excludeFilters = {
    @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RequestHeaderParameterProcessor.class, RequestParamParameterProcessor.class})
})
public class FeignConfiguration {

    @Bean
    public WebMvcRegistrations feignWebRegistrations() {
        return new FeignMvcRegistrations();
    }

    @Bean
    public RequestHeaderParamParameterProcessor getRequestHeaderParamParameterProcessor() {
        return new RequestHeaderParamParameterProcessor();
    }

    @Bean
    public GetRequestParamParameterProcessor getGetRequestParamParameterProcessor() {
        return new GetRequestParamParameterProcessor();
    }
}
